package org.kordakus.shoot.gui;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

import net.miginfocom.swing.MigLayout;

public class ImportProgressDialog extends JDialog
{

	private static final long	serialVersionUID	= -4446808679014065816L;

	private final ShootFrame	_frame;

	private JLabel				_statusLabel;
	private JProgressBar		_progressBar;

	public ImportProgressDialog(final ShootFrame frame)
	{
		super(frame);
		this._frame = frame;
		initializeObject();
	}

	private void initializeObject()
	{
		this.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill][]"));
		this.setResizable(true);
		this.setSize(450, 200);
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		this.setBackground(Color.LIGHT_GRAY);

		_statusLabel = new JLabel("...");
		_progressBar = new JProgressBar();

		JPanel bodyPanel = new JPanel(new MigLayout("ins 10", "[grow,fill]", "[][]10[]"));
		bodyPanel.setOpaque(true);
		bodyPanel.setBackground(Color.WHITE);
		bodyPanel.add(new JLabel("Importing..."), "wrap");
		bodyPanel.add(_statusLabel, "wrap");
		bodyPanel.add(_progressBar);

		JPanel footPanel = new JPanel(new MigLayout("ins 10", "[grow,fill][align right]", "[]"));
		footPanel.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createMatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY),
				BorderFactory.createMatteBorder(1, 0, 0, 0, Color.WHITE)));
		footPanel.setOpaque(true);
		// footPanel.setBackground(Color.LIGHT_GRAY);

		JButton cancelButton = new JButton("Cancel");

		footPanel.add(new JLabel(""));
		footPanel.add(cancelButton);

		this.add(bodyPanel, "wrap");
		this.add(footPanel, "");
		this.setVisible(true);
	}

	public void setProgress(int percentage)
	{
		this._progressBar.setValue(percentage);
	}

	public void setStatus(String message)
	{
		this._statusLabel.setText(message);
	}
}
